<?php
require_once('db.php');
require_once('utils.php');

$action = "all";

if (isset($_GET['user']) && !empty($_GET['user'])) {
	$action = "user";
	$userg = $_GET['user'];
}
if (isset($_GET['followees']) && !empty($_GET['followees'])) {
	$action = "followees_user";
}
if (isset($_GET['index']) && !empty($_GET['index'])) {
	$action = "index";
}

if($action != "index" && (!validUser($userg) || !existsUser($userg)))
{
	header("Location: $mainURL/404.php");
}

function rss_title()
{
	global $action;
	global $userg;
	global $siteName;
	print $siteName.": ";
	if($action == "index")
	{
		print "Todas";
	} else if($action == "user" || $action == "followees_user")
	{
		print $userg;
	}
}

?>
<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ?>
<?php echo "<?xml-stylesheet";?> href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?php echo "<?xml-stylesheet";?> href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
	<title><?php echo rss_title(); ?></title>
	
	<link><?=$mainURL?></link>
	<image><title><?=rss_title()?></title><link><?=$mainURL?></link><url><?=$mainURL?>/img/logo01-rss.gif</url></image>
	<description>Sitio colaborativo de publicación y comunicación entre blogs</description>
	<pubDate><?php echo date(DATE_RFC822); ?></pubDate>
	<generator>http://blog.meneame.net/</generator>
	<language>es</language>
	
<?php
  $all = (!empty($_GET['all'])) ? true : false;
  $todo = '';
  if($action == "index") {
    show_index_comments_rss($all);
  } else if (!empty($_GET['todo'])) {
    show_todo_comments_rss($all);
  }
  else
      show_comments_rss();

?>
</channel>
</rss>
